package router

import (
	v1 "wms/api/v1"
	"wms/middleware"

	"github.com/icetech233/gin"
)

func InitRouterV1(engine *gin.Engine) *gin.Engine {
	engine.Use(middleware.Cors(), middleware.LogRequest())
	engine.Use(gin.Logger(), gin.Recovery())
	// engine.Use(cors.Default())
	engine.GET("/ping", ping)
	engine.GET("/favicon.ico", faviconIco)
	engine.GET("/data/menu.json", menuJson)
	engine.GET("/api/record/log", recordLog)
	engine.POST("/api/record/log", recordLog)
	engine.GET("/api/env", envList)
	// engine.POST("/data/upload/excel", uploadExcel)
	//
	v1api := engine.Group("/api/v1")
	{
		g_upload := v1api.Group("/upload")
		g_upload.POST("/excel", uploadExcel)
		//
		g_spu := v1api.Group("/spu")
		g_spu.GET("/list", v1.SpuV1.SpuList)
		g_spu.POST("/add", v1.SpuV1.SpuAdd)
		g_sku := v1api.Group("/sku")
		g_sku.GET("/list", v1.SpuV1.SkuList)
		//
		g_attr := v1api.Group("/attr")
		g_attr.GET("/list", v1.AttrV1.AttrList)
		g_attr.POST("/add", v1.AttrV1.AttrAdd)
		g_attr.PUT("/edit", v1.AttrV1.AttrEdit)
		//
		g_menu := v1api.Group("/menu")
		g_menu.GET("/list", menuJson)
		g_menu.POST("/add", v1.MenuV1.MenuAdd)
		//
		g_dict := v1api.Group("/dict")
		g_dict.GET("/list", v1.DictV1.DictList)
		//
		g_warehouse := v1api.Group("/warehouse")
		g_warehouse.GET("/list", v1.WarehouseV1.WarehouseList)
		g_warehouse.POST("/add", v1.WarehouseV1.WarehouseAdd)
		g_warehouse.PUT("/edit", v1.WarehouseV1.WarehouseEdit)
		//
		g_tenant := v1api.Group("/tenant")
		g_tenant.GET("/list", v1.TenantApiV1.TenantList)
		g_tenant.POST("/add", v1.TenantApiV1.TenantAdd)
		g_tenant.PUT("/edit", v1.TenantApiV1.TenantEdit)
		// sim卡
		g_sim := v1api.Group("/sim")
		g_sim.GET("/list", v1.SimApiV1.List)
		// 库存
		g_stock := v1api.Group("/stock")
		g_stock.GET("/statistics", v1.StockApiV1.Statistics)
		g_stock.GET("/sku/list", v1.StockApiV1.SkuList)
		// 入库
		g_stock.POST("/in/add", v1.StockApiV1.InAddApply)
		// 通过/拒绝
		g_stock.POST("/in/audit", v1.StockApiV1.InAudit)
		g_stock.GET("/in/list", v1.StockApiV1.InList)
		g_stock.GET("/in/detail", v1.StockApiV1.InDetail)
		// 出库
		g_stock.POST("/out/add", v1.StockApiV1.OutAddApply)
		// 通过/拒绝
		g_stock.POST("/out/audit", v1.StockApiV1.OutAudit)
		g_stock.GET("/out/list", v1.StockApiV1.OutList)
		g_stock.GET("/out/detail", v1.StockApiV1.OutDetail)
		//
	}
	return engine
}
